//
//  LLMethodSwizzTool.m
//  Receipt
//
//  Created by admin on 2019/6/5.
//  Copyright © 2019 admin. All rights reserved.
//

#import "LLMethodSwizzTool.h"

@implementation LLMethodSwizzTool

+ (void)methodSwizzWithClass:(Class)class OriginSEL:(SEL)originSel swizzSEL:(SEL)swizzSel
{
    Method om = class_getInstanceMethod(class, originSel);
    Method nm = class_getInstanceMethod(class, swizzSel);
    
    
    BOOL addM = class_addMethod(class, originSel, method_getImplementation(nm), method_getTypeEncoding(nm));
    if (addM) {
        class_replaceMethod(class, swizzSel, method_getImplementation(om), method_getTypeEncoding(om));
    } else {
        method_exchangeImplementations(om, nm);
    }
}

@end
